#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        int left = 0, right = nums.size() - 1;
        vector<int> ret(2);
        while (left != right)
        {
            if (nums[left] + nums[right] < target) left++;
            else if (nums[left] + nums[right] > target) right--;
            else
            {
                ret[0] = nums[left];
                ret[1] = nums[right];
                break;
            }
        }
        return ret;
    }
};